package tsg.component;

import tsg.graphic.Color;
import tsg.graphic.Font;
import tsg.laf.LookAndFeel;
import tsg.laf.LookAndFeelManager;
import tsg.util.Dimension;

public class Label extends Component implements TextComponent
{
	/**
	 * 
	 */
	public Label()
	{
		this("");
	}
	
	/**
	 * 
	 * @param text
	 */
	public Label(String text)
	{
		this( text, 
			  LookAndFeelManager.getFont(LookAndFeel.KEY_LABEL_FONT), 
			  LookAndFeelManager.getColor(LookAndFeel.KEY_LABEL_FOREGROUNDCOLOR));
	}
	
	
	/**
	 * 
	 * @param text
	 */
	public Label(String text, Color foregroundColor)
	{
		this(text, LookAndFeelManager.getFont(LookAndFeel.KEY_LABEL_FONT), foregroundColor);
	}
	
	/**
	 * 
	 * @param text
	 * @param font
	 */
	public Label(String text, Font font)
	{
		this(text, font, LookAndFeelManager.getColor(LookAndFeel.KEY_LABEL_FOREGROUNDCOLOR));
	}
	
	/**
	 * 
	 * @param text
	 * @param font
	 */
	public Label(String text, Font font, Color foregroundColor)
	{
		this.setUI					(LookAndFeelManager.getComponentUI	(LookAndFeel.KEY_LABEL_COMPONENTUI));
		this.setBackgroundColor		(LookAndFeelManager.getColor		(LookAndFeel.KEY_LABEL_BACKGROUNDCOLOR));
		this.setForegroundColor		(foregroundColor);
		this.setFont				(font);

		this.setText				(text);
		this.setPreferredSize		(this.getTextSize());
	}
	
	/**
	 * 
	 * @return
	 */
	public Dimension getTextSize()
	{
		return new Dimension(_font.getStringWidth(_text), _font.getFontHeight());
	}
	
	/**
	 * 
	 */
	public String getText() 
	{
		return _text;
	}


	/**
	 * 
	 */
	public void setText(String text) 
	{
		_text = text;
	}
	
	
	public void setFont(Font font)
	{
		_font = font;
	}
	
	public Font getFont()
	{
		return _font;
	}

	
	private String _text = null;
	private Font   _font = null;
}








